﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Home : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            if (Session["fullname"] != null)
                Label2.Text = "Wellcome : " + Session["fullname"].ToString();

            LoadData();
           
        }
    }

    private void LoadData()
    {
        ManagementContract dt = new ManagementContract();
        DataSet ds = dt.GetNewContract();
        GridView1.DataSource = ds;

        Label4.Text = ds.Tables[0].Rows.Count+"";
        DataBind();
    }

    protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
    {
        ManagementContract processCon = new ManagementContract();
        processCon.FeasibilityContract(Int32.Parse(GridView1.SelectedDataKey[0].ToString()));
        Response.Redirect("FormContract.aspx?ContractID=" + GridView1.SelectedDataKey[0]);
    }
    protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {
        ManagementContract dt = new ManagementContract();
        dt.NotFeasibility(Int32.Parse(e.Keys[0].ToString()));
        LoadData();
    }
    protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        GridView1.PageIndex = e.NewPageIndex;
    }
}